package client;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.Socket;
import common.Constants;



public class Client implements Runnable {

	private Socket socket;
	private ObjectInputStream reader;
	private ObjectOutputStream writer;

	private String[][] TempMap=new String[6][6]; 



	@Override
	public void run() {
		try {	
			socket=new Socket("localhost",Constants.PORT);
			reader=new ObjectInputStream(socket.getInputStream());
			writer=new ObjectOutputStream(socket.getOutputStream());
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			System.out.print("IO");
		}
	}



	public   String[][] receive() throws IOException, ClassNotFoundException{
		TempMap=(String[][])reader.readObject();
		for(int i=0;i<6;i++){
			for(int j=0;j<6;j++){
				System.out.print(TempMap[i][j]);
			}
			System.out.println();
		}
		return TempMap;
	}
	
	public String receiveNormal() throws IOException, ClassNotFoundException{
		String str;
		str=(String) reader.readObject();
		return str;
	}

	public  void send(String str) throws IOException{

		writer.writeObject(str);
		writer.flush();
	}




}
